//#include<iostream>
//#include<algorithm>
//using namespace std;
//const int N = 1e6 + 10;
//int st[N],l[N],r[N];
//int len(int u)
//{
//	int a = len(l[u]);
//	int b = len(r[u]);
//	if (u == 0) return max(a, b) + 1;
//}
//int main()
//{
//	int count = 0,n;cin >> n;
//	for (int i = 1; i <= n; i++)
//	{
//		int a, b;cin >> a >> b;
//		st[a]++;
//		if (st[a] == 1) l[a] = b;
//		else if (st[a] == 2) r[a] = b;
//	}
//	len(1);
//	return 0;
//}
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
const int N = 1e6 + 10;
int m, k;
vector<int> tree[N];
queue<int> q;
int bfs(int u)
{
	int ret = 0;
	q.push(1);
	while (q.size())
	{
		int sz = q.size();
		 ret = max(ret, sz);
		while (sz--)
		{
			int t = q.front();q.pop();
			for (auto v : tree[t])
			{
				q.push(v);
			}
		}
	}
	return ret;
}
int dfs(int u)
{
	int ret = 0;
	for (auto v : tree[u])
	{
		ret = max(ret,dfs(v));
	}
	return ret + 1;
}
int main()
{
	int n;cin >> n;
	for (int i = 1; i < n; i++)
	{
		int a, b;cin >> a >> b;
		tree[a].push_back(b);
	}
	cout << dfs(1) << endl;
	cout << bfs(1) << endl;
	return 0;
}